//
//  ButtonItem.swift
//  Maze24
//
//  Created by Mars on 2020/11/7.
//

import Foundation

enum ButtonCategory: Hashable {
  case number(Int)
  case op(Op)
  case empty
}

extension ButtonCategory {
  var isNumber: Bool {
    switch self {
    case .number(_):
      return true
    default:
      return false
    }
  }
  
  var isOp: Bool {
    switch self {
    case .op(_):
      return true
    default:
      return false
    }
  }
}

struct ButtonItem: Hashable {
  let index: Int
  let category: ButtonCategory
}

extension ButtonItem {
  var title: String {
    switch category {
      case .number(let value): return String(value)
      case .op(let op): return op.rawValue
      case .empty: return ""
    }
  }
  
  var value: Int? {
    switch category {
      case .number(let v):
        return v
      default:
        return nil
    }
  }
  
  var op: Op? {
    switch category {
    case .op(let o):
      return o
    default:
      return nil
    }
  }
}

struct SettingButtonItem: Hashable {
  let image: String
  let text: String
}
